﻿using System;
using System.Windows.Forms;
using ADO.Beans.Beans.Class;
using ADO.Bussines.Class;

namespace ADO.NET
{
    public partial class Form1 : Form
    {
        private VoPersona miVoPersona;
        private readonly PersonaFacade miFacadePersona = new PersonaFacade();
        //private readonly FacadePersona miFacadePersona = new FacadePersona();
        //private DaoPersona p = new DaoPersona();


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LoadGrid();
        }

        private void btnGuardar_Click(object sender, EventArgs e)
        {
            /*var persona = new PERSONA 
            { 
                nitPersona = txtCedula.Text, 
                nombrePersona = txtNombre.Text 
            };
            miFacadePersona.InsertarPersona(persona);
            LoadGrid();*/
 


            miVoPersona = new VoPersona
            {
                Cedula = txtCedula.Text, 
                Nombre = txtNombre.Text 
            };
            miFacadePersona.InsertarPersona(miVoPersona);
            LoadGrid();
        }

        private void LoadGrid()
        {
            //dgvLista.DataSource = p.ListaPersonas();

            dgvLista.DataSource = miFacadePersona.ListadoPersonas();
            dgvLista.DataMember = "PERSONA";
        }
        
    }
}